<template>
	<view class="bgIndex ">
		<liu-slide-img :list="listPoster" :autoplay="autoplay" :interval="interval"
			@click="clickSlideImg"></liu-slide-img>

		
		<view class="padding20 buildingInformation">
			<view class="font-weight_bold">
				搭子信息
			</view>
			<view class="">
				<view class="flex-between margin-top_40rpx">
					<view class=" ">
						类型
					</view>

					<view class="flex" @click="subTypeFn()">
						<text>{{classify}}</text>
						<uni-icons type="right" size="15"></uni-icons>
					</view>


				</view>
				<view class="flex-between margin-top_40rpx" @click="location()">
					<view class=" ">
						地点
					</view>

					<view class="flex">
						<text>{{place?place:'请选择活动地点'}}</text>
						<uni-icons type="right" size="15"></uni-icons>
					</view>


				</view>
				<view class=" myNmae flex-between margin-top_40rpx ">
					<view class=" ">
						标题
					</view>
					<view class="">
						<input class="uni-input" v-model="form.title" placeholder="请填写标题" />
					</view>


				</view>
				<view class=" myNmae flex-between margin-top_40rpx " v-if="form.sex==1">
					<view class=" ">
						人数
					</view>
					<view class="">
						<input class="uni-input" type="number" v-model="form.people_number" placeholder="请输入活动人数" />
					</view>


				</view>


				<view class="flex-between margin-top_40rpx">
					<view class="">
						性别
					</view>
					<radio-group v-model="form.sex" name="apply" @change="handleApplyType">
						<!-- 	<label class="m-right10">
							<radio :checked="form.sex ==0" class="min-radio" value="1" color="#67C23A" />
							<text>性别不限</text>
						</label> -->
						<label class="m-right10">
							<radio :checked="form.sex ==1" class="min-radio" value="1" color="#67C23A" />
							<text>男女不限</text>
						</label>
						<label>
							<radio :checked="form.sex ==2" class="min-radio" value="2" color="#67C23A" />
							<text>男女比例</text>
						</label>
					</radio-group>
				</view>

				<view class="" v-if="form.sex==2">
					<view class="flex-between">
						<view class="">
							<input  class="uni-inputsa" type="number" v-model="form.man_price"
								:placeholder="'请输入男生参与搭子('+currency_name+')'" />
						</view>
						<view class="">
							<input @input="e=>handleInputChange(e,1)" class="uni-inputsa" type="number" v-model="form.man_number"
								placeholder="请输入男生活动人数" />
						</view>
					</view>
					<view class="flex-between">
						<view class="">
							<input class="uni-inputsa" type="number" v-model="form.woman_price"
								:placeholder="'请输入女生参与搭子('+currency_name+')'" />
						</view>
						<view class="">
							<input @input="e=>handleInputChange(e,2)" class="uni-inputsa" type="number" v-model="form.woman_number"
								placeholder="请输入女生活动人数" />
						</view>
					</view>
				</view>
				<view class="margin_20rpx_0" style="color: red;">
					<text>提示： <text style="color: red;">1</text>块钱等于<text
							style="color: red;">{{basicConfiguration.recharge_ratio}}</text><text>{{currency_name}}报名费是用户{{currency_name}}参与报名</text>

					</text>
				</view>


				<!-- <view class="myNmae flex-between margin-top_60rpx">
					<text style="min-width: 150rpx;">开始时间</text>
					<picker mode="date" :value="date" :fields="currentTimeFn(currentTime)" :start="startDate"
						:end="endDate" @change="bindDateChange">
						<view class="flex-align-center-justify-start  color6">
							<view class="" v-if="yeartime&&monthtime&&daytime">
								{{ yeartime }}
								<text>-</text>
								{{ monthtime }}
								<text>-</text>
								{{ daytime }}
								<uni-icons type="right" color='#333' size="16"></uni-icons>
							</view>
							<view class="" v-else>
								<text>活动开始时间</text>
								<uni-icons type="right" color='#333' size="16"></uni-icons>
							</view>

						</view>

					</picker>
				</view> -->
				<!-- 	<view class="myNmae flex-between margin-top_60rpx">
					<text style="min-width: 150rpx;">截止时间</text>
					<picker mode="date" :value="date1" :fields="currentTimeFn1(createTime1)" :start="startDate1"
						:end="endDate1" @change="bindDateChange1">
						<view class="flex-align-center-justify-start  color6">
							<view class="" v-if="yeartime1&&monthtime1&&daytime1">
								{{ yeartime1 }}
								<text>-</text>
								{{ monthtime1 }}
								<text>-</text>
								{{ daytime1 }}
								<uni-icons type="right" color='#333' size="16"></uni-icons>
							</view>
							<view class="" v-else>
								<text>报名截止时间</text>
								<uni-icons type="right" color='#333' size="16"></uni-icons>
							</view>

							

						</view>

					</picker>
				</view> -->
				<view class="myNmae flex-between margin-top_60rpx">
					<text style="min-width: 150rpx;">活动开始时间</text>

					<view class="flex-align-center-justify-start  color6">

						<view class="flex">
							<xp-picker placeholder='活动开始时间' v-model="form.activity_time" mode='ymdhi' ref="picker1"
								@confirm="confirm1" />

							<uni-icons @click="show1" type="right" color='#333' size="16"></uni-icons>
						</view>



					</view>


				</view>

				<view class="myNmae flex-between margin-top_60rpx">
					<text style="min-width: 150rpx;">活动报名截止时间</text>

					<view class="flex-align-center-justify-start  color6">
						<!-- <view class="" v-if="yeartime1&&monthtime1&&daytime1">
				    		{{ yeartime1 }}
				    		<text>-</text>
				    		{{ monthtime1 }}
				    		<text>-</text>
				    		{{ daytime1 }}
				    		<uni-icons type="right" color='#333' size="16"></uni-icons>
				    	</view> -->
						<view class="flex">
							<xp-picker placeholder='活动报名截止时间' v-model="form.expire_time" mode='ymdhi' ref="picker"
								@confirm="confirm" />

							<uni-icons @click="show" type="right" color='#333' size="16"></uni-icons>
						</view>



					</view>


				</view>
				<view style="margin-top:20rpx" class="">
					<text style="color:red">须知：选择活动截止时间应需要小于活动开始时间 </text>
				</view>
				<!-- 	<uni-forms-item label="营业开始时间" labelWidth="180px" name="businessHoursStart">
				
				
				</uni-forms-item>
				<uni-forms-item label="营业结束时间" labelWidth="180px" name="businessHoursEnd">
					<view class="selectProject" >
						<xp-picker placeholder='请选择营业结束时间'  v-model="form.businessHoursEnd" mode='hi' ref="picker1" @confirm="confirm" />
					
						<uni-icons  @click="show1" class="dropDownicons" color="#999" type="bottom" size="14">
							
						</uni-icons>
							
					</view>
				
				</uni-forms-item> -->
				<view class=" myNmae flex-between margin-top_40rpx " v-if="form.sex==1">
					<view class=" ">
						{{'报名费('+currency_name+')'}}
					</view>
					<view class="">
						<input class="uni-input" type="number" v-model="form.price"
							:placeholder="'请填输入活动金额('+currency_name+')'" />
					</view>


				</view>
				<view class="margin_20rpx_0">
					<text>注明:采用平台货币形式出售, <text style="color: red;">1</text>块钱等于<text
							style="color: red;">{{basicConfiguration.recharge_ratio}}</text>{{currency_name}}
					</text>
				</view>

				<sunui-upimg1 class="margin-top_20rpx" :border="'1px dashed #bfbfbf'" :formData="imgFormData"
					:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传活动图"
					:uploadServerUrl="upPicUrl" ref="selectimgandupload" @uploaded="imgLoaded" @change="imgsChange"
					:maxFileNumber="1"><template v-slot:icon>
						<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
					</template></sunui-upimg1>


				<sunui-upimg1 class="margin-top_20rpx" :border="'1px dashed #bfbfbf'" :formData="imgFormData1"
					:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传详情图"
					:uploadServerUrl="upPicUrl1" ref="selectimgandupload1" @uploaded="imgLoaded1" @change="imgsChange1"
					:maxFileNumber="5"><template v-slot:icon>
						<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
					</template></sunui-upimg1>


			</view>

		</view>
		<view class="padding20 margin-top_20rpx rightInput" style="background-color: #fff;">
			<view class="font-weight_bold">
				联系方式
			</view>
			<!-- <view class="myNmae  flex-between margin-top_40rpx ">
				<view class=" ">
					微信号
				</view>
				<view class="">
					<input class="uni-input" v-model="form.wechat" placeholder="请输入微信号方便联系" />
				</view>

			</view> -->

			<view class=" myNmae flex-between margin-top_40rpx ">
				<view class=" ">
					手机号
				</view>
				<view class="">
					<input class="uni-input" maxlength="11" v-model="form.phone" placeholder="请输入手机号方便联系" />
				</view>

			</view>

		</view>
		<view class="padding20 margin-top_20rpx" style="background-color: #fff;">
			<view class="personalTags">
				<view>
					<view class="font-weight_bold">
						需求标签
					</view>
					<view class="tag_container">
						<zy-tag ref="zyAddTag" addible closable @delete="deleteTag(item)"
							v-for="(item, index) in tagAddList" :text="item"></zy-tag>
						<view class="zy_tag_add"><text class="zy_tag_add_input" @click="addTag()">+ 自定义</text></view>
					</view>
				</view>
			</view>

		</view>
		<view class="padding20 margin-top_20rpx" style="background-color: #fff;">
			<view class="font-weight_bold">
				描述信息
			</view>
			<view class="textarea-box">
				<piaoyiEditor :values="form.describe" :maxlength="3000" @changes="saveContens" :photoUrl="photoUrl"
					:api="api" :name="name" />
				<!-- <textarea v-model="form.describe" placeholder="请输入自己的个人优势" maxlength="50" @input="descInput"
					style="height: 150rpx;" />
				<view class="textarea-color">{{ remnant }}/50</view> -->
			</view>

		</view>

		<view class="release flex" @click="releaseFn()">
			{{isEdit?'立即编辑':'立即发布'}}
		</view>
		<view class="" style="height: 20rpx;">

		</view>
		<!-- 添加标签 弹出框 -->
		<sunui-popup ref="pop">
			<template v-slot:content>

				<view class="v-pop-cls flex-column">
					<view class="text-align_right " style="width: 90%;">


						<uni-icons type="closeempty" @click="closeTag()" size="20"></uni-icons>

					</view>
					<text class="margin-right_50rpx">添加标签</text>
					<input placeholder="请输入2到6个字标签" v-model="singleLabel" />
					<view class="flex add" @click="singleLabelClick()">添加</view>
				</view>
			</template>
		</sunui-popup>
	</view>
</template>

<script>
	import piaoyiEditor from '@/uni_modules/piaoyi-editor/components/piaoyi-editor/piaoyi-editor.vue';
	import zyTag from '@/uni_modules/zy-tag/components/zy-tag/zy-tag.vue'
	export default {
		components: {
			zyTag,
			piaoyiEditor
		},
		data() {
			const currentDate = this.getDate({
				format: true
			});
			return {
				currency_name: uni.getStorageSync('system').currency_name,
				userInfo: uni.getStorageSync("userInfo"),
				yeartime: '',
				//选择的月份
				monthtime: '',
				//选择的天数
				daytime: '',
				yeartime1: '',
				//选择的月份
				monthtime1: '',
				//选择的天数
				daytime1: '',
				date: null,
				date1: null,

				currentTime: '1',
				createTime1: '1',
				autoplay: true,

				interval: 3000,
				listPoster: [],

				classify: '请选择搭子类型',
				place: '请选择活动地点',
				gender: '请选择搭子性别',
				activityTime: '请选择活动时间',
				expireTime: '请选择结束时间',
				form: {
					// 标题
					title: '',
					// 标签
					label: '',
					// 描述
					describe: '',
					// 分类一级pid
					pid_tab: "",
					// 分类二级id
					son_tab: '',
					// 人数
					people_number: '',
					// 活动地点
					address: '',
					// 性别
					sex: '1',
					// 报名费
					price: '',
					// 图片
					img: '',
					// 活动时间
					activity_time: '',
					// 截止时间
					expire_time: '',
					// 手机号
					phone: '',
					// 微信号
					// wechat: '',
					// 详情图
					cover_img: '',
					uid: uni.getStorageSync("userInfo").id,
					dimension: "",
					longitude: '',
					man_number: '',
					woman_number: '',
					man_price: '',
					woman_price: ''




				},
				imgFormData: null,
				imgFormData1: null,
				storageMode: "2",
				header: null,
				upPicUrl: null,
				upPicUrl1: null,
				img: [],
				imgStr: [],
				img1: [],
				imgStr1: [],
				tagAddList: [],
				singleLabel: '',
				remnant: 0,
				isEdit: false,
				dimension: '',
				longitude: '',
				basicConfiguration: '',
				api:'11',
				name: 'file',
				photoUrl: '111',
				userInfoObj:null


			}
		},
		onLoad(options) {
			this.api = this.$api.upload
			this.basicConfigurationFn()
			this.userInfoFn()
			this.posterFn()
			
		
			
			if (options.id) {



				const decodedData = {};
				for (const key in options) {
					// 解码当前字段的值
					const decodedValue = decodeURIComponent(options[key]);

					// 将解码后的值存储到新的对象中
					decodedData[key] = decodedValue;
				}


				this.form.id = decodedData.id
				this.$sun.assignObject(this.form, {
					...decodedData
				})
				this.init(this.form)
				this.place = this.form.address
				console.log(this.form)
				this.isEdit = true
				this.classify = decodedData.name
			}
		},
		onShow() {
			this.api = this.$api.upload
			this.basicConfigurationFn()
			this.$at.releaseKey('submit');
			if (uni.getStorageSync("tabClassIfy")) {
				this.classify = JSON.parse(JSON.stringify(uni.getStorageSync("tabClassIfy"))).name
				this.form.pid_tab = uni.getStorageSync("tabClassIfy").pid
				this.form.son_tab = uni.getStorageSync("tabClassIfy").id
			}
		},
		methods: {
			handleInputChange(e,sex){
				console.log(e.detail.value,sex)
				
				if(sex==1){
					this.form.people_number=Number(this.form.woman_number)+Number(e.detail.value)
				}else if(sex==2){
					this.form.people_number=Number(e.detail.value)+Number(this.form.man_number)
				}
			},
			saveContens(e) {
				console.log(e)
				this.form.describe = e.html
			},
			confirm(e) {
				console.log(e.value)
				this.form.expire_time = e.value
			},
			show() {
				this.$refs.picker.show()
			},
			confirm1(e) {
				console.log(e.value)
				this.form.activity_time = e.value
			},
			show1() {
				this.$refs1.picker.show()
			},
			async posterFn() {
				const resPoster = await this.$http.post({
					url: this.$api.poster,
					data: {

						type: 7

					},
					headers: {

					}

				})

				if (resPoster.code == 0) {




					// 	// 展示区域  1 首页 2 商城 3 套餐卡市场 这里还需要区分

					this.listPoster = resPoster.data.filter(item => item.type == 7);
					console.log(this.listPoster)




				} else {

					this.$sun.toast(resPoster.message, 'none')
				}



			},
			async userInfoFn() {
				const result = await this.$http.post({
					url: this.$api.userInfo,
					data: {
			
						// id:this.userInfo.id
			
			
					},
					headers: {
						'Authorization': this.userInfo.token
					}
			
				})
			
				if (result.code == 0) {
					console.log('data', result.data);
					wx.setStorageSync('userInfo', result.data);
					this.userInfoObj=result.data
				
					
			
				}
			},
			async basicConfigurationFn() {
				const result = await this.$http.post({
					url: this.$api.config,
					data: {


					},
					headers: {
						'Authorization': this.userInfo.token
					}

				})
				
				if (result.code == 0) {
					console.log(result)
					wx.setStorageSync('system', result.data);
					this.basicConfiguration = result.data
					if(  uni.getStorageSync("userInfo").level_id==1?(!Number(this.basicConfiguration.dazi_number)):(!Number(this.basicConfiguration.level_dazi_number))){
						this.$sun.toast("发布搭子已达上限", 'none')
						
					}
					else if(  uni.getStorageSync("userInfo").level_id==1?( Number( uni.getStorageSync("userInfo").daziNumber)>=Number(this.basicConfiguration.dazi_number)): ( Number( uni.getStorageSync("userInfo").daziNumber)>=Number(this.basicConfiguration.level_dazi_number)) ){
						this.$sun.toast("发布搭子已达上限", 'none')
						
					}

				}
			},
			init(options) {
				this.$nextTick(() => {
					const cover_imgList = options.cover_img.split(',').map((item) => item.trim());
					console.log(cover_imgList)
					this.$refs.selectimgandupload1.setItems(cover_imgList);

					this.$refs.selectimgandupload.setItems([options.img]);
				})
				this.tagAddList = this.form.label.split(',')
				this.form.activity_time = this.convertTimestampToDate(options.activity_time)
				console.log(this.activityTime)
				// this.yeartime = this.activityTime.year
				// this.monthtime = this.activityTime.month
				// this.daytime = this.activityTime.day
				// this.form.activity_time = `${this.yeartime}-${this.monthtime}-${this.daytime}`
				this.form.expire_time = this.convertTimestampToDate(options.expire_time)

				// this.yeartime1 = this.expireTime.year
				// this.monthtime1 = this.expireTime.month
				// this.daytime1 = this.expireTime.day
				// this.form.expire_time = `${this.yeartime1}-${this.monthtime1}-${this.daytime1}`
			},
			convertTimestampToDate(timestamp) {
				// 创建一个新的Date对象，传入时间戳作为参数
				const date = new Date(timestamp * 1000); // 时间戳以秒为单位，因此需要乘以1000转换为毫秒

				// 提取年、月、日
				const year = date.getFullYear(); // 获取年份
				const month = ('0' + (date.getMonth() + 1)).slice(-2); // 获取月份，并补零
				const day = ('0' + date.getDate()).slice(-2); // 获取日期，并补零
				const hours = ('0' + date.getHours()).slice(-2); // 获取小时数，并补零
				const minutes = ('0' + date.getMinutes()).slice(-2); // 获取分钟数，并补零
				// 返回包含年、月、日的对象
				return `${year}-${month}-${day} ${hours}:${minutes}`;

			},
			releaseFn() {
				if (this.userInfo.disable == 0) {
					this.$sun.toast('该用户已被拉黑', 'none')
				}else{
					if (uni.getStorageSync("userInfo").real_name||(!Number(this.basicConfiguration.isOpen_idCard_authentication)) ) {
						this.$at.uniDoFunc({
							key: 'submit',
							success: async () => {
								this.$at.lockKey('submit');
								if( this.userInfoObj.level_id==1?(!Number(this.basicConfiguration.dazi_number)):(!Number(this.basicConfiguration.level_dazi_number))){
									this.$sun.toast("发布搭子已达上限", 'none')
									this.$at.releaseKey('submit');
								}
								else if( this.userInfoObj.level_id==1?( Number(this.userInfoObj.daziNumber)>=Number(this.basicConfiguration.dazi_number)): ( Number(this.userInfoObj.daziNumber)>=Number(this.basicConfiguration.level_dazi_number)) ){
									this.$sun.toast("发布搭子已达上限", 'none')
									this.$at.releaseKey('submit');
								}
								// 登录 需要进行判断当前账号密码 和账号归属店铺及角色是否又选择
								else if (!this.form.title) {
									this.$sun.toast("请填写标题", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.label) {
									this.$sun.toast("请选择标签", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.describe) {
									this.$sun.toast("请填写个人优势", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.pid_tab && this.form.son_tab) {
									this.$sun.toast("请选择搭子分类类型", 'none')
									this.$at.releaseKey('submit');
								}  else if (!/^1[3456789]\d{9}$/.test(this.form.phone)) {
									this.$sun.toast("请填写正确手机号", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.address) {
									this.$sun.toast("请选择活动地点", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.img) {
									this.$sun.toast("请上传活动图", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.cover_img) {
									this.$sun.toast("请上传详情图", 'none')
									this.$at.releaseKey('submit');
								} else if (!this.form.activity_time && !this.form.expire_time) {
									this.$sun.toast("请填写开始结束时间", 'none')
									this.$at.releaseKey('submit');
								} else {
									if (!this.form.people_number||this.form.people_number==0) {
										this.$sun.toast("请填写搭子人数", 'none')
										this.$at.releaseKey('submit');
									}else{
										if(this.form.sex==1){
											 if (!this.form.price) {
												this.$sun.toast("请填写报名价格", 'none')
												this.$at.releaseKey('submit');
											}else{
												console.log(this.form)
												
												const saveOrUpdate = this.isEdit ? this.$api.updateDazi : this.$api.addDazi;
												const result = await this.$http.post({
													url: saveOrUpdate,
													data: {
														...this.form
												
													},
													headers: {
														'Authorization': this.userInfo.token
													}
												
												})
												if (result.code == 0) {
												
													this.$sun.toast(result.message, 'none')
													uni.removeStorageSync('tabClassIfy')
													setTimeout(() => {
														this.$sun.navBack()
													}, 500)
												
												
												
												} else {
													this.$sun.toast(result.message, 'none')
												}
												
												this.$at.releaseKey('submit');
											}
										}else{
											if (!this.form.man_number) {
												this.$sun.toast("请填写男生活动人数", 'none')
												this.$at.releaseKey('submit');
											} else if (!this.form.woman_number) {
												this.$sun.toast("请填写女生活动人数", 'none')
												this.$at.releaseKey('submit');
											}else if(!this.form.man_price){
												this.$sun.toast("请填写男生参与搭子价格", 'none')
												this.$at.releaseKey('submit');
											}else if(!this.form.woman_price){
												this.$sun.toast("请填写男生参与搭子价格", 'none')
												this.$at.releaseKey('submit');
											}else{
												console.log(this.form)
												
												const saveOrUpdate = this.isEdit ? this.$api.updateDazi : this.$api.addDazi;
												const result = await this.$http.post({
													url: saveOrUpdate,
													data: {
														...this.form
												
													},
													headers: {
														'Authorization': this.userInfo.token
													}
												
												})
												if (result.code == 0) {
												
													this.$sun.toast(result.message, 'none')
													uni.removeStorageSync('tabClassIfy')
													setTimeout(() => {
														this.$sun.navBack()
													}, 500)
												
												
												
												} else {
													this.$sun.toast(result.message, 'none')
												}
												
												this.$at.releaseKey('submit');
											}
										}
									}
									
									
								}
							}
						});
					} else {
						this.$sun.toast('请实名认证后在来发布','none')
						setTimeout(() => {
							this.$sun.navGo('/pagesA/personalCenter/informationIdCard')
											
						}, 1000)
					}
				}
				




			},

			// 日期获取
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;

				return `${year}-${month}-${day}`;

			},

			bindDateChange(e) {


				this.createTime = e.detail.value
				console.log(e.detail.value)
				this.form.activity_time = e.detail.value
				this.date = e.target.value;
				/* 在上面声明变量，split是用来截取字段*/
				this.yeartime = this.date.split('-')[0];
				this.monthtime = this.date.split('-')[1];
				this.daytime = this.date.split('-')[2];


			},
			bindDateChange1(e) {

				console.log(e)
				this.createTime1 = e.detail.value
				this.form.expire_time = e.detail.value
				this.date1 = e.target.value;
				/* 在上面声明变量，split是用来截取字段*/
				this.yeartime1 = this.date1.split('-')[0];
				this.monthtime1 = this.date1.split('-')[1];
				this.daytime1 = this.date1.split('-')[2];


			},
			handleApplyType(e) {
				let val = e.detail.value;
				this.form.sex = val;
				console.log(e.detail.value);
				if (this.form.sex == 1) {
					this.form.man_number = '',
					this.form.woman_number = '',
					this.form.man_price = '',
					this.form.woman_price = ''
				}else{
					this.form.price='',
					this.form.people_number=Number(this.form.woman_number)+Number(this.form.man_number)
				}

			},
			// 备注
			descInput(e) {
				this.remnant = e.detail.value.length;
				if (this.remnant >= 50) {
					this.$sun.toast('说明字数已达上限');
				}
			},
			location() {
				this.$sun.chooseLocation({
					lat: this.userInfo.dimension,
					lng: this.userInfo.longitude
				}).then((res) => {
					console.log(res)
					this.form.address = res.address;
					this.place = res.address;
					this.form.dimension = res.latitude;
					this.form.longitude = res.longitude;
				})
				
				// uni.chooseLocation({
				// 	success: res => {
				// 		this.form.address = res.name;
				// 		this.place = res.name;
				// 		this.form.dimension = res.latitude;
				// 		this.form.longitude = res.longitude;
				// 		console.log('获取定位信息res============', res);
				// 	}
				// });
			},
			subTypeFn() {

				this.$sun.navGo('/pagesB/index/classifyAll', {
					type: 1
				})
			},
			// ‘添加标签’弹出框
			addTag() {
				this.$refs.pop.show({
					anim: 'center',
					shadeClose: false,
					topclose: false
				});
			},
			// 弹窗——添加/修改单个标签
			singleLabelClick() {
				if (!this.singleLabel) {
					this.$sun.toast('请先输入标签');
				} else {
					this.updateTags();
				}
			},
			// 技师员工标签添加修改
			async updateTags() {
				// const result = await this.$http.put({
				// 	url: this.$api.updatePersonalTags,
				// 	data: {
				// 		id: '2', //修改时传值
				// 		label: this.singleLabel //添加的标签值
				// 	}
				// });


				this.$sun.toast('添加成功！');
				this.addTag2()
				this.closeTag();
			},

			// 关闭 ‘添加标签’弹出框
			closeTag() {
				this.$refs.pop.close();
			},
			//删除标签
			deleteTag(item) {
				console.log(item);
				// 2种删除方式
				// this.tagDeleteList.splice(this.tagDeleteList.indexOf(item), 1);
				this.tagAddList = this.tagAddList.filter(o => {
					return o !== item;
				});
			},
			//添加标签input框回车事件
			addTag2() {
				this.tagAddList.push(this.singleLabel);
				this.form.label = this.tagAddList.join(",")
				this.singleLabel = '';
			},
			// 上传图片返回
			imgLoaded(e) {
				console.log(e)

				this.img = [];
				for (let i = 0; i < e.length; i++) {
					this.img.push(e[i].url);
				}


				this.imgStr = this.img

				this.form.img = this.imgStr.length === 1 ? this.imgStr[0].toString() : this.imgStr
					.join(',');
			},

			imgsChange(file) {

				console.log('上传发生改变this.storageMode1111============', this.storageMode, '参数file', file);


				if (file.length) {
					this.upPicUrl = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData = {
						file: file,
						getsize: file.size?file.size:3000,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload.upload(); //图片上传
					});
				} else {
					this.form.img = '',
						this.imgStr = []
				}
				// this.niuyunLoop(file,0)

			},

			imgLoaded1(e) {
				console.log(e)

				this.img1 = [];
				for (let i = 0; i < e.length; i++) {
					this.img1.push(e[i].url);
				}


				this.imgStr1 = this.img1

				this.form.cover_img = this.imgStr1.length === 1 ? this.imgStr1[0].toString() : this.imgStr1
					.join(',');

				console.log(this.form.cover_img)
			},

			imgsChange1(file) {

				console.log('上传发生改变this.storageMode1111============', this.storageMode, '参数file', file);


				if (file.length) {
					this.upPicUrl1 = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData1 = {
						file: file,
						getsize: file.size,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload1.upload(); //图片上传
					});
				} else {
					this.form.cover_img = '',
						this.imgStr1 = []
				}
				// this.niuyunLoop(file,0)

			},
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			},
			startDate1() {
				return this.getDate('start');
			},
			endDate1() {
				return this.getDate('end');
			},
			currentTimeFn() {
				return function(currentIndex) {
					if (currentIndex == '1') {
						// 日
						return 'day';

					} else if (currentIndex == '2') {
						// 月
						return 'month';
					} else if (currentIndex == '3') {
						// 年
						return 'year';
					}
				};
			},
			currentTimeFn1() {
				return function(currentIndex) {
					if (currentIndex == '1') {
						// 日
						return 'day';

					} else if (currentIndex == '2') {
						// 月
						return 'month';
					} else if (currentIndex == '3') {
						// 年
						return 'year';
					}
				};
			}




		},
	}
</script>

<style lang="less" scoped>
	.bgIndex {
		.bg {

			height: 392.42rpx;
		}

		.rightInput {

			input {
				text-align: right;
			}
		}

		.buildingInformation {
			border-radius: 20rpx 20rpx 0rpx 0rpx;
			margin-top: -20rpx;
			z-index: 50;
			position: relative;
			background: rgb(255, 255, 255);

			.uni-inputsa {
				width: 85%;
				height: 90rpx;
				border-radius: 20rpx;
				background: #fff;
				border: 1rpx solid #E0E0E0;
				margin: 20rpx 0;
				padding: 0rpx 20rpx;
			}

			.myNmae {

				background-color: #fff;
				min-width: 50rpx;

				.avatar {
					width: 84rpx;
					height: 84rpx;
				}

				input {
					text-align: right;
				}

				.backgroundImg {

					height: 154rpx;


				}

			}
		}

		.personalTags {
			margin: 36rpx 0;

			.tag_container {
				margin-top: 36rpx;
				display: flex;
				align-items: center;
				flex-direction: row;
				// justify-content: space-between;
				flex-wrap: wrap;
			}

			.zy_tag_add {
				width: 150rpx;

				height: 50rpx; //medium：45rpx；small：40rpx；mini：35rpx
				padding: 5rpx 15rpx;
				margin: 5rpx 8rpx;
				border: 2rpx solid rgb(237, 237, 237);
				border-radius: 10rpx;
				text-align: center;
			}
		}

		.release {
			margin: 0 20rpx;
			height: 102rpx;
			border-radius: 142rpx;
			color: #fff;
			background: rgb(120, 93, 246);
		}

		.textarea-box {
			margin-top: 24rpx;
			border: 2rpx dashed #1e6ceb;
			background: #fff;
			padding: 30rpx;
			border-radius: 20rpx;

			.textarea-color {
				text-align: right;
				color: #999;
			}
		}

		// “添加标签” 弹出框
		.v-pop-cls {
			padding: 46rpx 0 88rpx;
			width: 710rpx;
			height: auto;
			position: relative;
			border-radius: 20rpx;
			background: #fff;

			image {
				width: 52rpx;
				height: 52rpx;
				position: absolute;
				padding: 30rpx;
				top: 0rpx;
				right: 0rpx;
			}

			text {
				color: #000;
				font-size: 36rpx;
			}

			input {
				// text-align: center;
				padding: 0 20rpx;
				width: 608rpx;
				height: 94rpx;
				margin: 62rpx 0;
				border-radius: 20rpx;
				background: #f5f5f5;
			}

			.add {
				width: 638rpx;
				height: 88rpx;
				background: #1890ff;
				color: #fff;
				font-size: 32rpx;
			}
		}
	}
</style>